
package com.shop.cloud.mall.api.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shop.cloud.common.core.util.R;
import com.shop.cloud.common.portal.annotation.ApiLogin;
import com.shop.cloud.mall.api.service.DistributionUserService;
import com.shop.cloud.common.portal.util.ThirdSessionHolder;
import com.shop.cloud.mall.common.entity.DistributionUser;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 分销员
 *
 * @author
 * @date 2021-04-25 17:40:35
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/distributionuser")
@Tag(description = "distributionuser", name = "分销员API")
public class DistributionUserController {

    private final DistributionUserService distributionUserService;

	/**
     * 分销员分页列表
     * @param page 分页对象
     * @param distributionUser 分销员
     * @return
     */
    @Operation(summary = "分销员分页列表")
    @GetMapping("/page")
	@ApiLogin
    public R getPage(Page page, DistributionUser distributionUser) {
        return R.ok(distributionUserService.page1(page, distributionUser));
    }

    /**
     * 当前用户分销员查询
     * @return R
     */
    @Operation(summary = "当前用户分销员查询")
    @GetMapping
	@ApiLogin
    public R getById() {
        return R.ok(distributionUserService.getDistributionUser(ThirdSessionHolder.getUserId()));
    }

}
